// 认证调试工具
export const authDebug = {
  log: (message, data = null) => {
    const timestamp = new Date().toLocaleString('zh-CN')
    console.log(`[认证调试 ${timestamp}] ${message}`, data || '')
  },
  
  logAuthState: () => {
    const token = localStorage.getItem('accessToken')
    const domain = window.location.hostname
    const path = window.location.hash.replace('#', '') || window.location.pathname
    const hasCode = new URLSearchParams(window.location.search).get('code')
    
    authDebug.log('当前认证状态', {
      hasToken: !!token,
      tokenLength: token ? token.length : 0,
      domain,
      path,
      hasCode: !!hasCode,
      fullUrl: window.location.href
    })
  },
  
  clearAuthState: () => {
    localStorage.removeItem('accessToken')
    authDebug.log('已清除认证状态')
  }
}

// 在开发环境下暴露到全局
if (process.env.NODE_ENV === 'development') {
  window.authDebug = authDebug
}